import 'package:flutter_elf/_base/build_config.dart';
/// CreateTime 2020/4/26 13:13
/// CreateUser chen 
/// ProjectName flutter_elf
import 'package:flutter_elf/config/component_index.dart';

import 'package:device_info/device_info.dart';
import 'package:package_info/package_info.dart';
class AppInfoPage extends BaseWidget{
  @override
  BaseWidgetState<BaseWidget> getState() {
    // TODO: implement getState
    return AppInfoPageState();
  }
}

class AppInfoPageState extends BaseWidgetState<AppInfoPage>{

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    initInfo();
  }

  initInfo()async{
  }

  @override
  Widget buildView(BuildContext context) {
    if(BuildConfig.isIos){
      return Container(
        margin: EdgeInsets.symmetric(horizontal: 20),
        child: Column(
          children: <Widget>[
            FutureBuilder<IosDeviceInfo>(
              builder: (context,snap){
                return Text(
                  '''
                  identifierForVendor=============>${snap.data.identifierForVendor}\n,
                  name=============>${snap.data.name}\n,
                  systemName=============>${snap.data.systemName}\n,
                  systemVersion=============>${snap.data.systemVersion}\n,
                  model=============>${snap.data.model}\n,
                  localizedModel=============>${snap.data.localizedModel}\n,
                  isPhysicalDevice=============>${snap.data.isPhysicalDevice}\n,
                  utsname=============>${snap.data.utsname}\n,
                  '''
                );
              },
            ),
          ],
        ),
      );
    }


    // TODO: implement buildView
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 20),
      child: Column(
        children: <Widget>[
          FutureBuilder<AndroidDeviceInfo>(
            future: DeviceInfoPlugin().androidInfo,
            builder: (context,snap){
              if(snap?.hasData ?? false){
                return Text(
                    "id======>" + snap.data.id +  "\n" +
                        "androidId======>" + snap.data.androidId +  "\n" +
                        "board======>" + snap.data.board +  "\n" +
                        "bootloader======>" + snap.data.bootloader +  "\n" +
                        "brand======>" + snap.data.brand +  "\n" +
                        "device======>" + snap.data.device +  "\n" +
                        "display======>" + snap.data.display +  "\n" +
                        "fingerprint======>" + snap.data.fingerprint  + "\n" +
                        "hardware======>" + snap.data.hardware  + "\n" +
                        "host======>" + snap.data.host  + "\n" +
                        "isPhysicalDevice======>" + snap.data.isPhysicalDevice.toString()  +  "\n" +
                        "manufacturer======>" + snap.data.manufacturer  + "\n" +
                        "model======>" + snap.data.model  + "\n" +
                        "product======>" + snap.data.product  + "\n" +
                        "tags======>" + snap.data.tags  + "\n" +
                        "type======>" + snap.data.type  + "\n" +
                        "version===baseOS===>" + snap.data.version.baseOS + '\n'
                        "version===codename===>" + snap.data.version.codename + '\n'
                        "version===incremental===>" + snap.data.version.incremental + '\n'
                        "version===previewSdkInt===>" + snap.data.version.previewSdkInt.toString() + '\n'
                        "version===sdkInt===>" + snap.data.version.sdkInt.toString() + '\n'
                        "version===previewSdkInt===>" + snap.data.version.previewSdkInt.toString()+'\n'
                );
              }return Text('===');
            },
          ),

        FutureBuilder<PackageInfo>(
          future: PackageInfo.fromPlatform(),
          builder: (context,snap){
            if(snap?.hasData ?? false){
              return Text(
                      "version========>" + snap.data.version +   "\n" +
                      "appName========>" + snap.data.appName +   "\n" +
                      "buildNumber========>" + snap.data.buildNumber +   "\n" +
                      "packageName========>" + snap.data.packageName
              );
            }return Text('===');
          },
        ),

          //分辨率
          Text(
            '分辨率' +
            MediaQuery.of(context).size.height.toString() + '\n'
            + MediaQuery.of(context).size.width.toString() + '\n'
            + MediaQuery.of(context).devicePixelRatio.toString() + '\n'

          ),


        ],
      ),
    );
  }

  @override
  PreferredSizeWidget initAppbar() {
    // TODO: implement initAppbar
    return AppBarCreator.create(context, 'app信息');
  }

}